#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll mymax=0;
	ll prev=-1;
	ll k=1;
	int i=2000;
	while(i--)
	{	
		char a;
		char b;
		ll x;
		cin>>a>>b>>x;
		if(a!=b)
		{
			k=0;
			 
			continue;
		}
		
		if(prev==-1)
		{
			k=1;
			prev=x; 
		}
		else
		{
			if(x-prev<=1000)
			{
				k++;
				prev=x;
			}
			else
			{
				k=1;
				prev=x;
			}
			//mymax=max(mymax,k);
		}
		 
		mymax=max(mymax,k);
	}	
	cout<<mymax;
	return 0;
 } 
